package com.allwees.bs.c.module.order.repository;

import com.allwees.bs.c.module.base.repository.BaseRepository;
import com.allwees.bs.c.module.order.entity.CartEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Set;

public interface CartRepository extends BaseRepository<CartEntity, Integer> {
    @Query(value = "SELECT c from CartEntity c "
    		+ "WHERE c.userUuid=:userUuid")
    CartEntity getByUser(@Param("userUuid") String userUuid);

    @Query(value = "From CartEntity c WHERE c.uuid=:uuid")
    CartEntity getByUuid(@Param("uuid") String uuid);

    @Query(value = "From CartEntity c WHERE c.uuid in :uuids")
    List<CartEntity> getByUuids(@Param("uuids") Set<String> uuids);

    @Query(value = " From CartEntity c WHERE c.uuid in :uuids")
    Set<CartEntity> getUserUuidByUuids(@Param("uuids") Set<String> uuids);

    List<CartEntity> findAllByUserUuid(String userUuid);
}
